﻿
Public Class m_empresa
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

  
    Protected Sub ImageButton1_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
        If txtempre.Text = "" Then
            Label1.Visible = True
            Label1emp.Visible = True
            Return

        Else
            Label1emp.Visible = False
            Label1.Visible = False

            If txttel.Text = "" Then

            Else

                If Not IsNumeric(txttel.Text) Then

                    Label1.Visible = True
                    Label1tel.Visible = True
                    Return
                Else
                    Label1tel.Visible = False
                    Label1.Visible = False

                End If
            End If


            If txtemail.Text = "" Then

            Else
                If Not txtemail.Text.Contains("@") Then

                    Label1.Visible = True
                    Label1email.Visible = True
                    Return
                Else
                    Label1email.Visible = False
                    Label1.Visible = False

                End If
            End If
            Dim query As String = String.Format("insert into empresas (nombreempresa, gerentegeneral , telefonoempresa,email,sitioweb ,observacion,direccion) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}')", txtempre.Text, txtgere.Text, txttel.Text, txtemail.Text, txtwebsite.Text, txtobse.Text, txtdireccion.Text)

            Dim con As New Devart.Data.PostgreSql.PgSqlConnection(seguridad.conexion)
            con.Open()
            Dim ejec As New Devart.Data.PostgreSql.PgSqlCommand(query, con)
            ejec.ExecuteNonQuery()
            con.Close()
            Try

            Catch ex As Exception
                MsgBox("No se pudo insertar a la base de datos")
            End Try

            txtempre.Text = ""
            txtgere.Text = ""
            txttel.Text = ""
            txtemail.Text = ""
            txtwebsite.Text = ""
            txtdireccion.Text = ""
            txtobse.Text = ""
            ASPxGridView1.DataBind()




        End If





    End Sub

    Protected Sub ImageButton6_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles ImageButton6.Click
        Dim sUrl As String = "../Reportes/frmempresa.aspx"
        Dim sScript As String = "<script language =javascript> "
        sScript += "window.open('" & sUrl & "',null,'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=500,height=300,left=100,top=100');"
        sScript += "</script> "
        Response.Write(sScript)
        Dim repot As New rptempresa
        repot.EmpresasTableAdapter.Fill(repot.DataSet11.empresas)

    End Sub
End Class